package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.ContactArchives;
import com.group.project.hrms.mapper.ContactArchivesMapper;
import com.group.project.hrms.service.IContactArchivesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class ContactArchivesService implements IContactArchivesService {

    @Autowired
    private ContactArchivesMapper contactArchivesMapper;


    @Override
    public int insertContactArchives(ContactArchives contactArchives) {
        return contactArchivesMapper.insert(contactArchives);
    }

    @Override
    public int deleteContactArchives(ContactArchives contactArchives) {
        return contactArchivesMapper.deleteByPrimaryKey(contactArchives);
    }

    @Override
    public int updateContactArchives(ContactArchives contactArchives) {
        return contactArchivesMapper.updateByPrimaryKey(contactArchives);
    }

    @Override
    public ContactArchives selectOneContactArchives(ContactArchives contactArchives) {
        return contactArchivesMapper.selectByPrimaryKey(contactArchives);
    }

    @Override
    public ContactArchives selectOneContactArchivesByContactID(String contactID) {
        Example example = new Example(ContactArchives.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("contactId" , contactID);
        return contactArchivesMapper.selectOneByExample(example);
    }

    @Override
    public List<ContactArchives> selectAllContactArchivesByStaffStatus(int status) {
        Example example = new Example(ContactArchives.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("staffStatus" , status);
        return contactArchivesMapper.selectByExample(example);
    }

    @Override
    public List<ContactArchives> selectAllContactArchives() {
        return contactArchivesMapper.selectAll();
    }
}
